package com.hontech.bvapp2.service

import com.hontech.bvapp2.ui.BaseActivity
import com.hontech.bvapp2.utils.Version
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.cbor.Cbor
import kotlinx.serialization.encodeToByteArray

private const val SCREEN_SHOT = "screen.shot"
private const val GET_VERSION = "get.version"

@OptIn(ExperimentalSerializationApi::class)
suspend fun onReq(msg: MsgItem): ByteArray {
    return when (msg.cmd) {
        SCREEN_SHOT -> onScreenShot()
        GET_VERSION -> Cbor.encodeToByteArray(Version)
        else -> byteArrayOf()
    }
}


private suspend fun onScreenShot(): ByteArray {
    return BaseActivity.INSTANCE.screenShot()
}




